from django.db import models

# Create your models here.

import datetime
import time

from smart_selects.db_fields import ChainedForeignKey


class Store(models.Model):
    def __unicode__(self):
        return self.name

    name = models.CharField(unique = True, max_length = 100)
    name.verbose_name = 'Store name'
    
    storeUrl = models.CharField(max_length = 100)

    class Meta:
        verbose_name = 'Store'
        verbose_name_plural = 'Stores'

class Category(models.Model):
    def __unicode__(self):
        return self.name

    store = models.ForeignKey(Store)
    name = models.CharField(max_length = 100)    
    category_id = models.CharField(max_length = 50)

    class Meta:
        verbose_name = 'Category name'
        verbose_name_plural = 'Categories'


class Product(models.Model):
    def __unicode__(self):
        return self.name
    store = models.ForeignKey(Store)
    category = ChainedForeignKey(
			Category, 
			chained_field="store",
			chained_model_field="store", 
			show_all=False, 
			auto_choose=True
    )   
    
    product_number = models.CharField(max_length = 20)
    name = models.CharField(max_length = 100)  
    regularPrice = models.CharField(max_length = 10)
    salePrice = models.CharField(max_length = 10)
    image = models.CharField(max_length = 100)    
    largeFrontImage = models.CharField(max_length = 100)
    largeImage = models.CharField(max_length = 100)
    leftViewImage = models.CharField(max_length = 100)
    rightViewImage = models.CharField(max_length = 100)
    topViewImage = models.CharField(max_length = 100)   

    mobileUrl = models.CharField(max_length = 200)

    class Meta:
        verbose_name = 'Product Name'
        verbose_name_plural = 'Products'
        

# Test models ======================================================================

